<!DOCTYPE HTML>
<html>

<head>
	<link rel="bookmark"  type="image/x-icon"  href="/img/logo_miccall.png"/>
	<link rel="shortcut icon" href="/img/logo_miccall.png">
	
			    <title>
    Ame雨
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/amelin-ting/css/mic_main.css" />
    <link rel="stylesheet" href="/amelin-ting/css/dropdownMenu.css" />
    <meta name="keywords" content="Ame雨" />
    
    	<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	 
    <noscript>
        <link rel="stylesheet" href="/amelin-ting/css/noscript.css" />
    </noscript>
    <style type="text/css">
        body:before {
          content: ' ';
          position: fixed;
          top: 0;
          background: url('/amelin-ting/img/bg.jpg') center 0 no-repeat;
          right: 0;
          bottom: 0;
          left: 0;
          background-size: cover; 
        }
    </style>

			    
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script async type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


    <script src="/amelin-ting/js/jquery.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrollex.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrolly.min.js"></script>
    <script src="/amelin-ting/js/skel.min.js"></script>
    <script src="/amelin-ting/js/util.js"></script>
    <script src="/amelin-ting/js/main.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>
    
		
<!-- Layouts -->



<!--  代码渲染  -->
<link rel="stylesheet" href="/css/prism_coy.css" />
<link rel="stylesheet" href="/css/typo.css" />
<!-- 文章页 -->
<body class="is-loading">
    <!-- Wrapper 外包 s-->
    <div id="wrapper" class="fade-in">
        <!-- Intro 头部显示 s -->
        <!-- Intro 头部显示 e -->
        <!-- Header 头部logo start -->
        <header id="header">
    <a href="/amelin-ting/" class="logo">Art Space</a>
</header>
        <!-- Nav 导航条 start -->
        <nav id="nav" class="special" >
            <ul class="menu links" >
			<!-- Homepage  主页  --> 
			<li >
	            <a href="/amelin-ting/" rel="nofollow">主页</a>
	        </li>
			<!-- categories_name  分类   --> 
	        
	        <li class="active">
	            <a href="#s1">分类</a>
	                    <ul class="submenu">
	                        <li>
	                        <a class="category-link" href="/amelin-ting/categories/Go/">Go</a></li><li><a class="category-link" href="/amelin-ting/categories/django/">django</a></li><li><a class="category-link" href="/amelin-ting/categories/drf/">drf</a></li><li><a class="category-link" href="/amelin-ting/categories/gin/">gin</a></li><li><a class="category-link" href="/amelin-ting/categories/go/">go</a></li><li><a class="category-link" href="/amelin-ting/categories/linux/">linux</a></li><li><a class="category-link" href="/amelin-ting/categories/mysql/">mysql</a></li><li><a class="category-link" href="/amelin-ting/categories/python/">python</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%89%8D%E7%AB%AF/">前端</a>
	                    </ul>
	        </li>
	        
	        <!-- archives  归档   --> 
	        
	        
		        <!-- Pages 自定义   -->
		        
		        <li>
		            <a href="/about/" title="简历">
		                简历
		            </a>
		        </li>
		        
		        <li>
		            <a href="/group/" title="团队">
		                团队
		            </a>
		        </li>
		        
		        <li>
		            <a href="/gallery/" title="图库">
		                图库
		            </a>
		        </li>
		        
		        <li>
		            <a href="/tag/" title="标签">
		                标签
		            </a>
		        </li>
		        


            </ul>
            <!-- icons 图标   -->
			<ul class="icons">
                    
                    <li>
                        <a title="github" href="https://github.com/miccall" target="_blank" rel="noopener">
                            <i class="icon fa fa-github"></i>
                        </a>
                    </li>
                    
                    <li>
                        <a title="500px" href="http://500px.com" target="_blank" rel="noopener">
                            <i class="icon fa fa-500px"></i>
                        </a>
                    </li>
                    
			</ul>
</nav>

        <div id="main" >
            <div class ="post_page_title_img" style="height: 25rem;background-image: url(https://img1.baidu.com/it/u=464477847,1248192382&amp;fm=26&amp;fmt=auto);background-position: center; background-repeat:no-repeat; background-size:cover;-moz-background-size:cover;overflow:hidden;" >
                <a href="#" style="padding: 4rem 4rem 2rem 4rem ;"><h2 >mysql关键字&amp;聚合函数</h2></a>
            </div>
            <!-- Post -->
            <div class="typo" style="padding: 3rem;">
                <h2 id="一、ROUND"><a href="#一、ROUND" class="headerlink" title="一、ROUND"></a>一、ROUND</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">1.什么是round</span><br><span class="line">	ROUND(f,p) 返回 f 舍入到 p 位小数。</span><br><span class="line">	小数位数可能是负数，这将四舍五入到最接近的 10（当 p 为 -1）或 100（当 p 为 -2）或 1000（当 p 为 -3）等。</span><br><span class="line">	可以保留小数并四舍五入</span><br><span class="line">        round(1231.86,0)  # 1232</span><br><span class="line">        round(1231.86,1)  # 1231.9</span><br><span class="line">        round(1231.86,-3)  # 1000</span><br><span class="line">2.语句演示</span><br><span class="line">	select name, round(population/1000,1) from xxx;</span><br></pre></td></tr></table></figure>

<h2 id="二、CASE"><a href="#二、CASE" class="headerlink" title="二、CASE"></a>二、CASE</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">1.什么是case</span><br><span class="line">	CASE 允许您在不同条件下返回不同的值。</span><br><span class="line">	如果没有任何条件匹配（并且没有 ELSE），则返回 NULL。</span><br><span class="line">	</span><br><span class="line">2.语句演示</span><br><span class="line">	case when 条件1 then 值1</span><br><span class="line">		when 条件2 then 值2</span><br><span class="line">		else def_valve end</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">	select name, population,</span><br><span class="line">	case when population&lt;1000000 then &#x27;small&#x27;</span><br><span class="line">         when population&lt;10000000 when &#x27;medium&#x27;</span><br><span class="line">         else &#x27;large&#x27; end</span><br><span class="line">    from world</span><br></pre></td></tr></table></figure>

<h2 id="三、ORDER-BY"><a href="#三、ORDER-BY" class="headerlink" title="三、ORDER BY"></a>三、ORDER BY</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是order by</span><br><span class="line">	能对数据进行升序降序排队</span><br><span class="line"></span><br><span class="line">2. 语句演示</span><br><span class="line">	select name, continent from world where name in (&#x27;Argentina&#x27;, &#x27;Australia&#x27;) order by name asc;  # ASC 升序</span><br><span class="line">	select name, continent from world where name in (&#x27;Argentina&#x27;, &#x27;Australia&#x27;) order by name desc;  # DESC 降序</span><br></pre></td></tr></table></figure>

<h2 id="四、CONCAT"><a href="#四、CONCAT" class="headerlink" title="四、CONCAT"></a>四、CONCAT</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是concat</span><br><span class="line">	可以拼接两个或者多个字符串</span><br><span class="line">	这个操作是串联</span><br><span class="line"></span><br><span class="line">2. 语句演示</span><br><span class="line">	select name, concat(population,&#x27;%&#x27;) from world;</span><br></pre></td></tr></table></figure>

<h2 id="五、SUM"><a href="#五、SUM" class="headerlink" title="五、SUM"></a>五、SUM</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是sum</span><br><span class="line">	求和</span><br><span class="line"></span><br><span class="line">2. 代码演示</span><br><span class="line">	select sum(gdp) from world where continent = &#x27;Africa&#x27;;</span><br></pre></td></tr></table></figure>

<h2 id="六、-MAX-amp-MIN"><a href="#六、-MAX-amp-MIN" class="headerlink" title="六、 MAX&amp;MIN"></a>六、 MAX&amp;MIN</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是max&amp;min</span><br><span class="line">	比较最大&amp;比较最小</span><br><span class="line"></span><br><span class="line">2. 代码演示</span><br><span class="line"> 	select post,max(salary) from emp group by post;</span><br><span class="line"></span><br><span class="line">	select post,min(salary) from emp group by post;</span><br></pre></td></tr></table></figure>

<h2 id="七、DISTINCT"><a href="#七、DISTINCT" class="headerlink" title="七、DISTINCT"></a>七、DISTINCT</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是distinct</span><br><span class="line">	去重</span><br><span class="line">	一定要注意 必须是完全一样的数据才可以去重！！！</span><br><span class="line">	一定不要将逐渐忽视了 有逐渐存在的情况下 是不可能去重的</span><br><span class="line"></span><br><span class="line">2. 代码演示</span><br><span class="line">	select distinct id,age from emp;</span><br></pre></td></tr></table></figure>

<h2 id="八、-COUNT"><a href="#八、-COUNT" class="headerlink" title="八、 COUNT"></a>八、 COUNT</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是count</span><br><span class="line">	可以总计次数</span><br><span class="line"></span><br><span class="line">2. 代码演示</span><br><span class="line">	select continent, count(name) from world group by continent</span><br></pre></td></tr></table></figure>

<h2 id="九、GROUP-BY"><a href="#九、GROUP-BY" class="headerlink" title="九、GROUP BY"></a>九、GROUP BY</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是group by</span><br><span class="line">	可以进行分组</span><br><span class="line">	简单来说：1、与distinct类似，自带去重效果</span><br><span class="line">    配合聚合函数使用&#123;sum()、max()、min()、avg()、count()&#125;</span><br><span class="line">    配合HAVING</span><br><span class="line"></span><br><span class="line">2. 代码演示</span><br><span class="line">	select continent, name from world group by continent</span><br></pre></td></tr></table></figure>

<h2 id="十、-HAVING"><a href="#十、-HAVING" class="headerlink" title="十、 HAVING"></a>十、 HAVING</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是having</span><br><span class="line">	&quot;&quot;&quot;</span><br><span class="line">    having的语法根where是一致的</span><br><span class="line">    只不过having是在分组之后进行的过滤操作</span><br><span class="line">    即having是可以直接使用聚合函数的</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    </span><br><span class="line">2. 代码演示</span><br><span class="line">	select continent from world group by continent having sum(population)&gt;100000000;</span><br></pre></td></tr></table></figure>

<h2 id="十一、JOIN"><a href="#十一、JOIN" class="headerlink" title="十一、JOIN"></a>十一、JOIN</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">1. 什么是join</span><br><span class="line">	合拼两个或多个表格</span><br><span class="line">	语句FROM 表示合拼两个表格game 和 goal的数据 ，语句 ON 表示如何找出 game中每一列应该配对goal中的哪一列</span><br><span class="line">2. 代码演示</span><br><span class="line">	select team1,team2,player from game join goal on (id=matchid) where player like &#x27;Mario%&#x27;;</span><br><span class="line">3. 补充知识</span><br><span class="line">	上述代码又可以写成 </span><br><span class="line">		select team1,team2,player from game,goal where id=matchid and player like &#x27;Mario%&#x27;;</span><br><span class="line">	如果是合拼三个表格</span><br><span class="line">		select name from movie,actor,casting where movie.id = movieid and actor.id = actorid and title = &#x27;Alien&#x27;;</span><br><span class="line">	三个表格 jion 写法</span><br><span class="line">		select name from movie join casting on movieid = movie.id join actor on actorid = actor.id where title = 		&#x27;Alien&#x27;；</span><br></pre></td></tr></table></figure>




            </div>

            <!-- Post Comments -->
            
    <!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
    <div id="disqus_thread"></div>

<!-- add animation -->
<style>
	.disqus_click_btn {
            line-height: 30px;
            margin: 0;
            min-width: 50px;
            padding: 0 14px;
            display: inline-block;
            font-family: "Roboto", "Helvetica", "Arial", sans-serif;
            font-size: 14px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0;
            overflow: hidden;
            will-change: box-shadow;
            transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
            outline: 0;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            vertical-align: middle;
            border: 0;
            background: rgba(158, 158, 158, .2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
            color: #fff;
            background-color: #7EC0EE;
            text-shadow: 0
        }
</style>
	
<div class="btn_click_load" id="disqus_bt"> 
    <button class="disqus_click_btn">点击查看评论</button>
</div>

<!--
<script type="text/javascript">
$('.btn_click_load').click(function() {
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'http-miccall-tech'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    document.getElementById('disqus_bt').style.display = "none";
});
</script>
-->
<script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'https://gitee.com/AmeX/amelin-ting.git/2018/06/02/MySQL------%E5%85%B3%E9%94%AE%E5%AD%97&amp;%E8%81%9A%E5%90%88%E5%87%BD%E6%95%B0/';  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = 'https://gitee.com/AmeX/amelin-ting.git/2018/06/02/MySQL------%E5%85%B3%E9%94%AE%E5%AD%97&amp;%E8%81%9A%E5%90%88%E5%87%BD%E6%95%B0/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
</script>

<script type="text/javascript">
    $('.btn_click_load').click(function() {  //click to load comments
        (function() { // DON'T EDIT BELOW THIS LINE
            var d = document;
            var s = d.createElement('script');
            s.src = '//http-miccall-tech.disqus.com/embed.js';
            s.setAttribute('data-timestamp', + new Date());
            (d.head || d.body).appendChild(s);
        })();
        $('.btn_click_load').css('display','none');
    });
</script>
</div>
<style>
    #disqus-comment{
        background-color: #eee;
        padding: 2pc;
    }
</style>


        </div>
        <!-- Copyright 版权 start -->
                <div id="copyright">
            <ul>
                <li>&copy;Powered By <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/" style="border-bottom: none;">hexo</a></li>
                <li>Design: <a target="_blank" rel="noopener" href="http://miccall.tech " style="border-bottom: none;">miccall</a></li>
            </ul>
            
                <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
			
        </div>
    </div>
</body>



 	
</html>
